package com.example.big_orange2.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.big_orange2.common.Result;
import com.example.big_orange2.entity.Staff;
import com.example.big_orange2.entity.lockrule;
import com.example.big_orange2.entity.pagedata_rule;
import com.example.big_orange2.entity.pagedata_s;
import com.example.big_orange2.mapper.lockruleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LockRuleService {
    @Resource
   lockruleMapper lockruleMapper;
    public Result<?> findPage(Integer page, Integer limit, String s){
        pagedata_rule ru=new pagedata_rule();
        LambdaQueryWrapper<lockrule> wrapper = Wrappers.<lockrule>lambdaQuery();
        if(StrUtil.isNotBlank(s)){//判断search不是空
            wrapper.like(lockrule::getLockclassid,Integer.parseInt(s));
        }
        Page<lockrule> ClientPage=lockruleMapper.selectPage(new Page<>(page,limit),wrapper);
        ru.setLockrulePage(ClientPage);
        ru.setTotal(ClientPage.getTotal());
        return  Result.success(ru);//返回结果

    }
}
